﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.DynamicData;

namespace NotAClue.ComponentModel.DataAnnotations
{
    /// <summary>
    /// Conditionally Required Attribute
    /// </summary>
    /// <remarks>Makes a column required when the parent column has a specified value.</remarks>
    [AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
    public class ConditionallyRequiredAttribute : Attribute
    {
        /// <summary>
        /// Gets or sets the name of the parent column.
        /// </summary>
        /// <value>The name of the column.</value>
        /// <remarks></remarks>
        public String ParentColumnName { get; set; }

        /// <summary>
        /// Gets or sets the value the parent column has when the condition is true.
        /// </summary>
        /// <value>The value when true.</value>
        /// <remarks></remarks>
        public String ValueWhenTrue { get; set; }

        public ConditionallyRequiredAttribute() { }

        /// <summary>
        /// Initializes a new instance of the <see cref="ConditionallyRequiredAttribute"/> class.
        /// </summary>
        /// <param name="columnName">The UI hint.</param>
        /// <param name="valueWhenTrue">The value when true.</param>
        /// <remarks></remarks>
        public ConditionallyRequiredAttribute(String parentColumnName, String valueWhenTrue)
        {
            ParentColumnName = parentColumnName;
            ValueWhenTrue = valueWhenTrue;
        }
    }
}